package com.c;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.RichTextString;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashSet;

public class ExcelUtil {
    public HashSet<String> getExeclDataSet() throws IOException {
        String filePath = "C:\\Users\\Raichard\\Desktop\\a\\dwyx.twb_e_qfjl_1_prt_p03.xlsx";
        File file = new File(filePath);
        FileInputStream in = new FileInputStream(file);
        //得到execl对象
        XSSFWorkbook sheets = new XSSFWorkbook(in);
        //获取第几个sheet
        XSSFSheet sheet = sheets.getSheetAt(0);
        int lastRowNum = sheet.getLastRowNum();
        System.out.println(lastRowNum);
        HashSet<String> strings = new HashSet<>();
        for (int i = 0; i <= lastRowNum; i++) {
            XSSFRow row = sheet.getRow(i);
            if (row.toString() != "") {
                XSSFCell cell = row.getCell(0);
                XSSFCell cell1 = row.getCell(1);
                String str = cell + "|+|" + cell1;
                strings.add(str);
            }

        }
        return strings;

    }
}
